#include <iostream>
#include <string>
#include <sstream>
#include <memory>
using namespace std;

class Date
{
private:
    int Day, Month, Year;
    string StringDate;
public:
    //Constructor
    Date(int inputDay, int inputMonth, int inputYear):Day(inputDay), Month(inputMonth), Year(inputYear)
    {

    }

    void DisplayDate(void)
    {
        cout << Year << "-" << Month << "-" << Day << endl;
    }

    operator const char*()
    {
        ostringstream mystring;
        //整形转字符串
        mystring << Year << "-" << Month << "-" << Day;
        StringDate = mystring.str();
        return StringDate.c_str();
    }
};

int main(int argc, char const *argv[])
{
/*    Date Holiday(4,6,2017);
    cout << Holiday << endl;*/
    unique_ptr<int> dynamicIntPtr(new int);
    *dynamicIntPtr = 42;
    //use smart pointer like an int pointer
    cout << *dynamicIntPtr << endl;
    //只能指针存入对象
    unique_ptr<Date> dynamicHoliday(new Date(6,4,2017));
    dynamicHoliday->DisplayDate();
    //no need to do the following when using unique ptr
/*    delete dynamicIntPtr;
    delete dynamicHoliday;*/
    return 0;
}
